package org.grottarossa.ui.core.casemanagement.menu;

import java.util.ResourceBundle;

import org.grottarossa.ui.core.ApplicationSession;
import org.grottarossa.ui.core.casemanagement.menu.process.StartableProcessMenuPanel;
import org.grottarossa.ui.core.i18n.DM;
import org.grottarossa.ui.core.layout.EmptyPanel;

import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.ui.Component;

public class MenuPanelFactory
{
	private static ResourceBundle m_localizer = DM.instance().getBundle(MenuPanelFactory.class.getName());

	public enum MenuPanelType {

		Service(0),
		ProcessTemplate(1),
		ProcessInstance(2),
		Query(3);

		int m_value = 0;

		MenuPanelType(int val) {
			m_value = val;
		}

		public int getValue()
		{
			return m_value;
		}
	}

	public static Component getMenuPanel(ApplicationSession appSession, String applicationName, MenuPanelType type, ItemClickListener itemClickListener) {

		Component component = null;

		switch ( type )
		{
		case Service:
			component = new ServicesMenuPanel(appSession, applicationName, m_localizer.getString("menu.services.caption"), itemClickListener);
			break;

		case ProcessTemplate:
			component = new  StartableProcessMenuPanel(appSession, applicationName, m_localizer.getString("menu.processetemplate.caption"), itemClickListener);
			break;

		case ProcessInstance:
			component = new QueriesMenuPanel(appSession, applicationName, "WF", m_localizer.getString("menu.processinstance.caption"), itemClickListener);
			break;

		case Query:
			component = new QueriesMenuPanel(appSession, applicationName, "CF", m_localizer.getString("menu.queries.caption"), itemClickListener);
			break;

		default:
			component = new EmptyPanel(m_localizer.getString("menu.error.caption"), m_localizer.getString("menu.error.message"));
			break;
		}


		return component;
	}
}
